#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QtSerialPort/QSerialPortInfo>
#include <QtSerialPort/QSerialPort>
#include <QMainWindow>
#include <QTimer>
#include <QRubberBand>
#include "qcustomplot.h"
#define N 16    //the byte of transfer once
namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();
    QTimer* timer = new QTimer(this);
    QTimer* distime = new QTimer(this);
private slots:
    void on_openserial_clicked();
    void on_closebutton_clicked();

    void on_senddata_button_clicked();
    void receiver();

    void on_black_line_button_clicked();


    void on_START_clicked();

    void on_STOP_clicked();

    void on_stop_receive_clicked();

    void on_start_receive_clicked();

    void on_stop_biack_line_clicked();

    void on_Read_Para_clicked();

    void on_rangex_textChanged();

    void on_rangey_textChanged();

    void mousePress(QMouseEvent* mevent);

    void mouseMove(QMouseEvent *mevent);

    void mouseRelease(QMouseEvent *mevent);

    void on_reset_black_clicked();

    void on_left_encoder_start_clicked();

    void on_start_comm_clicked();

private:
    Ui::MainWindow *ui;
    qint32 baudrate;
    QString serialname;
    qint32 databits;
    qint32 parity;
    qint32 stopbits;
    float black_x;
    QSerialPort serial;
    int AvailabeFlag;
    QByteArray receivedata;
    QByteArray SortedDate;
    QByteArray distancedata;
    char * receive;
    QByteArray senddata;
    QRubberBand *rubberBand;
    QPoint rubberOrigin;
};

#endif // MAINWINDOW_H
